##
##	CSCE 482 CAPSTONE, 2012
##	Texas A&M Univeristy
##	
##	Group Graffiti
##	Members:
##		Matt Shubert 
##		Balazs Makany
##		Eric Gonzalez 
##		Raj Shah
##		Fredy Laksmono
##
import sys
v_commands = 	[	'AUTH',\
					'GET',\
					'POST',\
					'UPDATE',\
					'ADMIN'\
				]

v_s_commands = 	[	'100',\
					'200',\
					'202',\
					'400',\
					'CONTENTID',\
					'CONTENTGPS',\
					'AROUND',\
					'STATUS',\
					'RESPONSE',\
					'MEMBERSHIP',\
					'ADD',\
					'REMOVE'\
				]
					

def command_to_sanitize(input):
	input = input.decode("windows-1252")
	if (len(input) > 255):
		return False
	
	words = input.split()

	if (words[0] not in v_commands):
		print "Unknown command: "+str(words[0])
		return False
	if (words[1] not in v_s_commands):
		print "Unknown subcommand: "+str(words[1])

	return (interpret(input))
	
def interpret(input_s):
	print "Valid looking command, now to interpret it..."
	
	words = input_s.split()
	print(len(words))
	
	### Valid Command Functions from Client
	if 	words[0] == "AUTH":
		if		len(words) == 2 and words[1] == "100":
			print "Hello Auth 100"
			
		elif	len(words) == 4 and words[1] == "202":
			print "Hello Auth 202"
		
		else:
			print "Invalid Auth"
			
	elif 	words[0] == "GET":
		if		len(words) == 4 and words[1] == "CONTENTGPS":
			print "Hello Get ContentGps"
			
		elif	len(words) == 4 and words[1] == "CONTENTID":
			print "Hello Get ContentId"
			return "Hello Get ContentId Return Value"
			
		elif	len(words) == 2 and words[1] == "AROUND":
			print "Hello Get Around"
			
		elif	len(words) == 4 and words[1] == "STATUS":
			print "Hello Get Status"
		
		else:
			print "Invalid Get"

	elif	words[0] == "POST":
		if		len(words) == 4 and words[1] == "CONTENTGPS":
			print "Hello Post ContentGps"
			
		elif	len(words) == 4 and words[1] == "CONTENTID":
			print "Hello Post ContentId"
			
		else:
			print "Invalid Post"
		
	elif	words[0] == "UPDATE":
		if		len(words) == 4 and words[1] == "MEMBERSHIP":
			if		words[2] == "ADD":
				print "Hello Update Membership Add"
				
			elif	words[2] == "REMOVE":
				print "Hello Update Membership Remove"
				
			elif	words[2] == "STATUS":
				print "Hello Update Membership Status"
		else:
			print "Invalid Update Membership"
			
	elif	words[0] == "ADMIN":
		if		len(words) == 4 and words[1] == "ADD":
			print "Hello Admin Add"
			
		elif	len(words) == 4 and words[1] == "REMOVE":
			print "Hello Admin Remove"
			
		elif	len(words) == 4 and words[1] == "STATUS":
			print "Hello Admin Status"
		
		else:
			print "Invalid Admin"
			
	else:
		print ("FALSE")
		return False


	
if __name__ == '__main__':
	command_to_sanitize('GET CONTENTID awesome 442342') 